package com.jumi.microservice.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jumi.microservice.dto.reponse.FenXiaoReponse;
import com.jumi.microservice.entity.CommonGroup;
import com.jumi.microservice.entity.JmUserFenxiao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;


/**
 * <p>
 * 用户收益表 Mapper 接口
 * </p>
 *
 * @author 要挑客户管理团队
 * @since 2020-07-14
 */
public interface JmUserFenxiaoMapper extends BaseMapper<JmUserFenxiao> {

    Page fenXiaoPage(Page page,@Param(Constants.WRAPPER) Wrapper wrapper);


    @Select("select IFNULL(sum(yongjin),0) yj from jm_user_fenxiao  ${ew.customSqlSegment}")
    BigDecimal getSumYongJin(@Param(Constants.WRAPPER)Wrapper wrapper);


    @Select("select IFNULL(sum(yongjin),0) yongjin,type,uid,buyer_id from jm_user_fenxiao  ${ew.customSqlSegment}")
    List<FenXiaoReponse> getSumYongJinByColumn(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select IFNULL(sum(yongjin),0) price,type from jm_user_fenxiao  ${ew.customSqlSegment}")
    List<CommonGroup> getSumYongJinByType(@Param(Constants.WRAPPER) Wrapper wrapper);

    Page getFenXiaoDetail(Page page,@Param(Constants.WRAPPER) Wrapper wrapper);
}
